package com.zhuiyun.project.api.courseSubscribe.controller;

import com.zhuiyun.project.annotation.OptLog;
import com.zhuiyun.project.api.courseSubscribe.model.CourseSubscribeModel;
import com.zhuiyun.project.api.courseSubscribe.model.CourseUpdateStatusModel;
import com.zhuiyun.project.api.courseSubscribe.service.CourseSubscribeService;
import com.zhuiyun.project.api.courseSubscribe.service.impl.CourseSubscribeServiceImpl;
import com.zhuiyun.project.common.controller.BaseController;
import com.zhuiyun.project.common.errorCode.CommonException;
import com.zhuiyun.project.common.response.CommonResult;
import com.zhuiyun.project.utils.constants.CommonConstants;
import com.zhuiyun.project.utils.pageUtil.PageRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.annotation.RequestScope;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName CourseSubscribeController
 * @Description TODO
 * @Author 胡家浩
 * @Date 2024/5/30 16:56
 **/
@RestController
@RequestMapping("courseSubscribe")
@Api(tags = "约课管理")
@Slf4j
public class CourseSubscribeController extends BaseController {
    @Autowired
    private CourseSubscribeService courseSubscribeService;

    /**
    * @Author 胡家浩
    * @Description 获取约课信息
    * @Date 2024/5/31 10:46
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param pageRequest
* @param venueUniqueIdentifier
* @param courseName
    */
    @ApiOperation(value = "获取约课信息")
    @OptLog(modular = "约课管理", type = CommonConstants.SELECT, describe = "select")
    @GetMapping("getCourseList")
    public CommonResult getCourseList (PageRequest pageRequest,String venueUniqueIdentifier,String courseName){
        return courseSubscribeService.getCourseList(pageRequest, venueUniqueIdentifier, courseName);
    }

    /**
    * @Author hjh
    * @Description 根据id获取课程信息
    * @Date 2024/5/31 16:28
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param id
* @param venueUniqueIdentifier
    */
    @ApiOperation(value = "根据id获取约课详情")
    @OptLog(modular = "约课管理", type = CommonConstants.SELECT, describe = "select")
    @GetMapping("getCourseInfoById")
    public CommonResult getCourseInfoById (String id,String venueUniqueIdentifier){
        return courseSubscribeService.getCourseInfoById(id, venueUniqueIdentifier);
    }

    /**
    * @Author hjh
    * @Description 新增课程信息
    * @Date 2024/6/2 21:05
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param files
* @param courseSubscribeModel
    */
    @ApiOperation(value = "新增课程")
    @PostMapping("addCourse")
    public CommonResult addCourse (@RequestBody MultipartFile[] files,CourseSubscribeModel courseSubscribeModel) throws CommonException {
        CommonResult result = courseSubscribeService.addCourse(files, courseSubscribeModel);
        return CommonResult.ok(result);
    }

    /**
    * @Author hjh
    * @Description 修改课程状态
    * @Date 2024/6/3 9:58
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param courseSubscribeModel
    */
    @ApiOperation(value = "修改课程信息")
    @PutMapping("updateCourseStatus")
    public CommonResult updateCourseStatus (@RequestBody CourseUpdateStatusModel courseSubscribeModel) throws CommonException {
        CommonResult result = courseSubscribeService.updateCourseStatus(courseSubscribeModel);
        return CommonResult.ok(result);
    }

    /**
    * @Author hjh
    * @Description 修改课程
    * @Date 2024/6/3 11:33
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param courseSubscribeModel
     * @param files
    */
    @ApiOperation(value = "修改课程")
    @PutMapping("updateCourseById")
    public CommonResult updateCourseById (MultipartFile [] files, CourseSubscribeModel courseSubscribeModel) throws CommonException{
        CommonResult result = courseSubscribeService.updateCourseById(files,courseSubscribeModel);
        return CommonResult.ok(result);
    }

    /**
    * @Author hjh
    * @Description 删除课程
    * @Date 2024/6/3 15:04
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param id
* @param venueUniqueIdentifier
    */
    @ApiOperation(value = "删除课程")
    @DeleteMapping("delCourse")
    public CommonResult delCourse (Integer id,String venueUniqueIdentifier){
        CommonResult result = courseSubscribeService.delCourse(id, venueUniqueIdentifier);
        return CommonResult.ok(result);
    }
}
